#!/usr/bin env python3
# filename: todo_list_models.py

import time
from datetime import datetime
from ext import db
from flask_login import UserMixin


class TodoList(db.Model):
    __tablename__ = "todolist"
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, nullable=False)
    title = db.Column(db.String(1024), nullable=False)
    status = db.Column(db.String(15), nullable=False)
    create_time = db.Column(db.Integer, nullable=False)

    def __init__(self, user_id, title, status):
        self.user_id = user_id
        self.title = title
        self.status = status
        self.create_time = int(time.time())


class User(UserMixin, db.Model):
    __tablename__ = "todolist_user"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(32), nullable=False)
    password = db.Column(db.String(32), nullable=False)

    def __init__(self, username, password):
        self.username = username
        self.password = password

